<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Loader extends CI_Loader {

	function view($view, $vars = array(), $return = FALSE) {

		$this->ci =& get_instance();
		$viewname = $this->ci->config->item('viewname');

		$folder_and_view = $viewname."/".$view;
		$fullpath = APPPATH."views/".$folder_and_view.".php";

		// Check if file exists otherwise take file from default folder
		if (!file_exists($fullpath)) {
			$folder_and_view = DEFAULTVIEWNAME."/".$view;
		}

		return $this->_ci_load(array('_ci_view' => $folder_and_view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
	}


}